<?php
/**
 * Created by PhpStorm.
 * User: dx
 * Date: 16/4/1
 * Time: 下午6:09
 */
$service_path = __DIR__ . "/../../../api/";
ob_start();
require_once($service_path . "public/index.php");
ob_end_clean();


echo date('Y-m-d H:i:s',time())." activity check cancel started \n";

$rs = DB::table('activity_base_info')
    ->where('status',1)
    ->where("begin_date","<=",date("Y-m-d H:i:s",time()))->get();

//print_r($rs);exit;

foreach($rs as $_one){
    DB::update('update activity_base_info set status = 1 where id = ?', array($_one->id));
    echo date('Y-m-d H:i:s',time())." id = [".$_one->id."] name = [".mb_convert_encoding($_one->name, "GBK", "UTF-8")."] is open\n";
}

$rs = DB::table('activity_base_info')
    ->where('status',1)
    ->where("end_date","<",date("Y-m-d",time()))->get();
foreach($rs as $_one){
    DB::update('update activity_base_info set status = 0 where id = ?', array($_one->id));
    echo date('Y-m-d H:i:s',time())." id = [".$_one->id."] name = [".mb_convert_encoding($_one->name, "GBK", "UTF-8")."] is close\n";
}

echo date('Y-m-d H:i:s',time())." activity check retry stoped \n";
